package LeetCodeHot100TopInterview;

public class Q300_LongestSubSequence {

    //最长递增子序列 注意 不是要求连续 无法使用窗口
    //直接上 dp
    public int lengthOfLIS(int[] nums) {
        if (nums == null || nums.length == 0){
            return 0;
        }
        int[] dp = new int[nums.length];
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < nums.length; i++) {
            dp[i] = 1;
            for (int j = 0; j < i ; j++) {
                if (nums[i] > nums[j]){
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
            max = Math.max(max, dp[i]);
        }
        return max;
    }

    public static void main(String[] args) {
        Q300_LongestSubSequence fun = new Q300_LongestSubSequence();
        System.out.println(fun.lengthOfLIS(new int[]{7,7,7,7,7,7,7}));
    }
}
